{include file="public/header" /}
<body>
<div class="layui-tab layui-tab-brief main-tab-container">
    <ul class="layui-tab-title main-tab-title">
        <a href="{:url('ad/lst')}"><li class="layui-this">广告列表</li></a>
        <a href="{:url('ad/add_ad')}"><li>添加广告</li></a>
        <div class="main-tab-item">广告管理</div>
    </ul>
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">
            <form class="layui-form" name="paixu" method="post" onsubmit="return false;">

                <table class="list-table">
                    <thead>
                    <tr>
                        <th>ID</th>
                        <th>广告名称</th>
                        <th>广告图片</th>
                        <th>创建时间</th>
                        <th>修改时间</th>
                        <th>操作</th>
                    </tr>
                    </thead>

                    <tbody>

                    <tr>
                        {volist name="lst" id="vo"}
                        <td>{$vo.id}</td>
                        <td>{$vo.title}</td>
                        <td><img src="{$vo.images}" width="20%"/> </td>
                        <td>{$vo.create_time|default=time()|date='Y-m-d  H:i:s',###}</td>
                        <td>{$vo.update_time|default=time()|date='Y-m-d  H:i:s',###}</td>

                        <td style="text-align: center;">
                            <a href="{:url('edit_ad',array('id'=>$vo['id']))}" class="layui-btn layui-btn-small" title="编辑"><i class="layui-icon"></i></a>
                            <a class="layui-btn layui-btn-small layui-btn-danger del_btn" category-id="1" title="删除" id="{$vo.id}"><i class="layui-icon"></i></a>
                        </td>
                        {/volist}
                    </tr>

                    </tbody>
                </table>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    //删除操作
    $(".del_btn").click(function(){
        var $this = $(this)
        var id=$this.attr('id');
        $.ajax({
            url: "{:url('ad/del_ad')}",
            data: {'id':id},
            type: "POST",
            datatype:"json",
            success: function( result ) {
                $this.parents('tr').remove();
                layer.open({
                    title: '信息'
                    ,content: '删除成功！'
                });
            }
        });
    });
    layui.use(['element', 'layer', 'form'], function(){
        var element = layui.element()
            ,jq = layui.jquery
            ,form = layui.form()
            ,laypage = layui.laypage;
    })
</script>
</body>
</html>